package org.lds.ers.client.widgets;

import org.lds.ers.client.MyInfo;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.VerticalPanel;

/*
 * 主選單
 */
public class MainMenu extends VerticalPanel {
	
	private static MainMenu singleton;
	public static MainMenu getInstance()
	{
		if (singleton == null)
			singleton = new MainMenu();
		
		return singleton;
	}
	
	
	private  MenuBar menu ;
	private MainMenu()
	{
		this.setWidth("150px");
		initializeUI();
	}
	
	private void initializeUI()
	{
		Command cmd0 = new Command() {
			public void execute() {
		        ContentArea.getInstance().setWidget(MaintainSysAdmin.getInstance());
		      }
		};
		Command cmd1 = new Command() {
		      public void execute() {
		        ContentArea.getInstance().setWidget(MaintainStake.getInstance());
		      }
		};
		Command cmd2 = new Command() {
		      public void execute() {
		        ContentArea.getInstance().setWidget(MaintainStakeERS.getInstance());
		      }
		};
		
		Command cmd3 = new Command() {
		      public void execute() {
		        ContentArea.getInstance().setWidget(MaintainWard.getInstance());
		      }
		};
		
		Command cmd4 = new Command() {
		      public void execute() {
//		        Window.alert("Ward ERSC");
		    	ContentArea.getInstance().setWidget(MaintainWardERS.getInstance());
		      }
		};
		
		Command cmd5 = new Command() {
		      public void execute() {
//		        Window.alert("Ward ERSC");
		    	ContentArea.getInstance().setWidget(MaintainResume.getInstance());
		      }
		};
		
		Command cmd6 = new Command() {
		      public void execute() {
//		        Window.alert("Ward ERSC");
		    	ContentArea.getInstance().setWidget(QueryResume.getInstance());
		      }
		};
		
	    this.menu = new MenuBar(true);
	    if (MyInfo.get().isAdmin())
	    {
	    	this.menu.addItem("設定管理者", cmd0);
			this.menu.addItem("管理支聯會", cmd1);
			this.menu.addItem("管理支聯會ERSC", cmd2);
			this.menu.addItem("管理支會", cmd3);
			this.menu.addItem("管理支會ERSC", cmd4);
	    }
	    
	    this.menu.addItem("維護履歷", cmd5);
	    this.menu.addItem("查詢履歷", cmd6);
		
		this.add(this.menu);
		this.addStyleName("menubar");
		
	}
}
